package com.magicsoft.share.presenter.share;

import com.magicsoft.share.base.BasePresenter;
import com.magicsoft.share.constant.APIService;
import com.magicsoft.share.constant.SPKey;
import com.magicsoft.share.rx_retrofit_network.location.retrofit.RetrofitUtil;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.LoadingTransformer;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.NetWorkTransformer;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.SimpleObserver;
import com.magicsoft.share.utils.SPUtils;
import com.magicsoft.share.view.share.ICommentWriteView;

import io.reactivex.annotations.NonNull;

/**
 * Created by lyf on 2017/11/28/028.
 */

public class CommentWritePresenter extends BasePresenter<ICommentWriteView> {
    public void commentWrite(long articleId,String comment) {
        RetrofitUtil.getApi(APIService.class)
                .addComment(SPUtils.getInstance().getString(SPKey.TOKEN), SPUtils.getInstance().getLong(SPKey.ID),
                        articleId,comment)
                .compose(new NetWorkTransformer())
                .compose(new LoadingTransformer(mContext))
                .subscribe(new SimpleObserver(mCompositeDisposable) {
                    @Override
                    public void call(@NonNull Object o) {

                        getView().commentWriteSuccess();
                    }
                });

    }
}
